# Regression test for #342:
# Possible null-pointer dereference in pb_decode.c

Import("env")

# Define the compilation options
opts = env.Clone()
opts.Append(CPPDEFINES = {'PB_OLD_CALLBACK_STYLE': 1})

# Build new version of core
strict = opts.Clone()
strict.Append(CFLAGS = strict['CORECFLAGS'])
strict.Object("pb_decode_oldcallback.o", "$NANOPB/pb_decode.c")
strict.Object("pb_encode_oldcallback.o", "$NANOPB/pb_encode.c")
strict.Object("pb_common_oldcallback.o", "$NANOPB/pb_common.c")

opts.NanopbProto("extensions")
testprog = opts.Program(["test_extensions.c", "extensions.pb.c", "pb_encode_oldcallback.o", "pb_decode_oldcallback.o", "pb_common_oldcallback.o"])

opts.RunTest(testprog)

